import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    static final int mod=109;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

            int n = in.nextInt();
            int m = in.nextInt();

            if(m==0){
                System.out.println(1);
                return;
            }
            long ret=n;
            for (int i=1;i<m;i++){
                ret=ret*(n-1)%mod;

            }
            System.out.println(ret);

    }
}
